home *** CD-ROM | disk | FTP | other *** search
/ Amiga Packmags / NewsFlash - Issue 19 (1991-08)(UGA - NewsFlash UK)(Disk 1 of 2).zip / NewsFlash - Issue 19 (1991-08)(UGA - NewsFlash UK)(Disk 1 of 2).adf / sources / testbitsort.c < prev   
C/C++ Source or Header  |  1978-01-06  |  902b  |  47 lines

  1.  
  2. /* BitSortTest.c */
  3.  
  4. #include <exec/types.h>
  5. #include <exec/io.h>
  6. #include <exec/memory.h>
  7. #include <proto/exec.h>
  8. #include <string.h>
  9.  
  10. #define TABLESIZE       10000
  11.  
  12. extern ULONG __regargs BitSortLongs (ULONG *, ULONG);
  13.  
  14. ULONG tablebit[TABLESIZE], tablequick[TABLESIZE];
  15.  
  16. main()
  17. {
  18.     ULONG secs1, secs2;
  19.     int i;
  20.  
  21.     for (i = 0; i < TABLESIZE; i++)
  22.         tablebit[i] = tablequick[i] = rand();
  23.  
  24.     puts ("\nSorting 1000 random numbers:\n");
  25.  
  26.     printf ("BitSort...");
  27.     time (&secs1);
  28.     BitSortLongs (tablebit, TABLESIZE);
  29.     time (&secs2);
  30.     printf ("%ld secs.\n\n", secs2 - secs1);
  31.  
  32.     printf ("SAS/C QuickSort...");
  33.     time (&secs1);
  34.     lqsort (tablequick, TABLESIZE);
  35.     time (&secs2);
  36.     printf ("%ld secs.\n\n", secs2 - secs1);
  37.  
  38.     puts ("Checking sorted arrays...");
  39.     for (i = 0; i < TABLESIZE; i++) {
  40.         if (tablebit[i] != tablequick[i]) {
  41.             /* Should NEVER happen !! */
  42.             puts ("Error!!!");
  43.             }
  44.         }
  45.     puts ("done.\n");
  46. }
  47.